package com.example.demo.controller;

import com.example.demo.entity.Articleinfo;
import com.example.demo.entity.Userinfo;
import com.example.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;



    @RequestMapping("/getuserbyid")
    public Userinfo getUserById(Integer id){
        if(id==null) return null;
        return userService.getUserById(id);
    }

    @RequestMapping("/getalluser")
    public List<Userinfo> getAllUser(){
        return userService.getAllUser();
    }

    @RequestMapping("/add")
    public int add(Userinfo userinfo){
        return userService.add(userinfo);
    }

    @RequestMapping("/delete")
    public int delete(int id){
        return userService.delete(id);
    }

    public int addGetId(Userinfo userinfo){
        return userService.addGetId(userinfo);
    }

    public int update(Userinfo userinfo){
        return userService.update(userinfo);
    }

    public List<Userinfo> getAllUserSort(String sort){
        return userService.getAllUserSort(sort);
    }
}
